import Vue 			from 'vue'
import util 		from '../../util'
import axios 		from 'axios'
import { Toast,Dialog } 	from 'vant';
Vue.use(Toast,Dialog);

export default {
	name: 'besuper',
	data(){
		return {
			// token:'',
		}
	},
	computed:{
		// locale(){
		// 	return this.$i18n.locale
		// },
		// isIphoneX(){
		// 	return util.isIphoneX()
		// },
		// isIphone(){
		// 	return util.client()
		// }
	},
	methods:{
		goApply(){
			let from = this.$route.query.from;
			let query = { death:1 }
			if(from && from === 'home'){
				query.from = 'home'
			}
			this.$router.replace({
				path:'/apply',
				query:query
			})
		},
		init(){
			util.fetch(`${util.ajaxUrl}/user-access/list`,{}).then(res => {
				if(res.retCode === 0){
					if(res.retData.partner_entrance == 1){
						//是超火
						window.location.href = window.location.origin + window.location.pathname+'#/invite';
						// this.$router.replace('/invite')
					}
				}else{
					Toast(res.retMsg || res.retHtml || res.retData || this.$t('noError'))
				}
			}).catch(e => {
				Toast(this.dialogSystemErr);
			})
		},
		goBack(){
			util.navigateBack(-1,this)
		}
	},
	created() {
		util.waitSDKReady().then(token => {
			this.token = token;
			if(token) this.init();
		}).catch((e) => {
			// Toast('获取token失败')
		})
		setTimeout(() => {
			//退出登录的时候native调用H5方法清除token缓存
			util.registerHandler('loginOutDeleteToken',res => {
				localStorage.removeItem('token');
			})
			util.callHandler('setStatusBarStyle',{
				style:'dark'
			})
		},500)
    }
}